<?php
/**
 * @file Newbirdentrym.php
 * @synopsis  用户引用
 * @author change
 * @version 1.0
 * @date 2015年10月20日18:18:13
 */

defined('BASEPATH') OR exit('No direct script access allowed');

class Newbirdentrym extends CI_Model
{
    function __construct()
    {

    }
    //获取商品列表
    public function get_newbirdentry_content($nocache)
    {
        $mc = $this->cache->memcached;
        $key = 'newbirdentry_content';

        if(!$this->cache->memcached->is_supported())
        {
            $result = array("code" => -3,'tips' => "缓存未开启");
        }

        $data = $mc->get($key);
        if($data && !$nocache)
        {
            $return = $data;
        }
        else
        {
            $ret = $this->db->select('id,desc,type_id,aim_id,images_thumb')->where("is_show",1)->limit(0,1)->get("ml_newbirdentry")->result_array();
            $return = [];
            foreach ($ret as $value) {
                $item = array();
                $item = $value;
                $item['images_thumb'] = ret_fullpath_url($value['images_thumb']);
                if($value['type_id'] == 4)
                {
                    $this->load->model('goodsm');
                    $goods_info = $this->goodsm->get_goods_info($value['aim_id']);
                    $item['jfpoints'] = $goods_info['jfpoints'];
                    $item['goods_info_usrl'] = WEB_URL."goods/goods_info/".$value['aim_id'];
                    $item['start_order_usrl'] = WEB_URL."goods/start_order/".$value['aim_id'];
                }
                else
                {
                    $item['aim_id'] =  $value['aim_id']; //如果是商品需要返回url
                }
                $return[] = $item;
            }
            $mc->save($key,$return, 60*10);
        }
        return $return[0];
    }
}